package io.zt.dangyuan;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by liuwei on 2016/9/9.
 */
public class AddressListSearchAdapter extends BaseAdapter {

    private Context context;
    private List<SeaListEntity> book;
    private LayoutInflater inflate;

    public AddressListSearchAdapter(Context context, List<SeaListEntity> book) {
        this.context = context;
        this.book = book;
        inflate = LayoutInflater.from(context);
    }


    @Override
    public int getCount() {
       return   book.size();
    }

    @Override
    public Object getItem(int i) {
        return book.get(i);
    }

    @Override
    public long getItemId(int i) {
        return book.size();
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        ViewHolder3 holder3;
        if (convertView == null) {
            holder3 = new ViewHolder3();
            convertView = inflate.inflate(R.layout.address_book_item, viewGroup, false);
            holder3.tv_itemName = (TextView) convertView.findViewById(R.id.addres_book_name);
            holder3.tv_itemphoen = (TextView) convertView.findViewById(R.id.addres_book_phone);
            holder3.iv_image = (CircleImageView) convertView.findViewById(R.id.addres_book_image2);
            holder3.tv_work_uint = (TextView) convertView.findViewById(R.id.tv_work_uint);
            holder3.iv_image.setBorderColor(Color.WHITE);
            holder3.iv_image.setBorderWidth(4);
            convertView.setTag(holder3);
        } else {
            holder3 = (ViewHolder3) convertView.getTag();
        }

        SeaListEntity object = book.get(i);
        holder3.tv_itemName.setText(object.getRealname());
        holder3.tv_itemphoen.setText(object.getMobile());
        holder3.tv_work_uint.setText(object.getWorkunit());
        return convertView;

    }

    class ViewHolder3 {
        TextView tv_itemName;
        TextView tv_itemphoen;
        CircleImageView iv_image;
        TextView tv_work_uint;
    }
}
